<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>补打小票</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <style>
        .ml10 {
            margin-left: 15px;
        }

    </style>
    <object  id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
        <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
    </object>

</head>

<body class="gray-bg" >
<div class="wrapper wrapper-content  animated fadeInRight" id="ccbb">
    <div class="row">
        <div class="col-sm-12">
            <%--<div class="toolbar">--%>
            <%--<div id="toolbar">--%>
            <%--<button id="btn_add" class="btn btn-primary"><i class="fa fa-plus-circle"></i>&nbsp;新增</button>--%>
            <%--<button id="btn_del" class="btn btn-w-s btn-danger"><i class="fa fa-times-circle"></i>&nbsp;批量删除</button>--%>
            <%--<button id="button" class="btn btn-primary " ><i class="fa fa-check-circle"></i>&nbsp;获取选中</button>--%>
            <%--<button id="btn_getCheck姓名" class="btn btn-primary " ><i class="fa fa-check-square"></i>&nbsp;获取选中ChekBox</button>--%>
            <%--</div>--%>
            <%--</div>--%>
            <span id="spancc" class="spancc"></span>
            <div class="row">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>搜索条件</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content" >
                        <div class="row">
                            <%--<div class="col-sm-4"><input placeholder="手机号或订单号" class="form-control" id="phoneOrOrderCode"></div>--%>
                            <div class="col-sm-2">
                                <select class="form-control" id="state">
                                    <option value="1">已付款</option>
                                    <option value="2">已退款</option>
                                    <%--<option value="3">错误订单</option>--%>
                                </select>
                            </div>
                            <%--<div class="col-sm-2"><input placeholder="开始日期" id="dateStart" class="form-control layer-date" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" id="start"></div>--%>
                            <%--<div class="col-sm-2"><input placeholder="结束日期" id="dateEnd" class="form-control layer-date" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" id="end"></div>--%>
                            <div class="col-sm-1"><button id="btn_search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;搜索</button></div>

                        </div>
                    </div>
                </div>
            </div>
            <table id="exampleTablePagination" class="table table-striped table-bordered table-hover"></table>
        </div>
    </div>
</div>

<div style="display:none;" id="print1">
    <body>
    <div>
        <div>久零网消费单据</div>
        <hr/>
        <div>
            <div>
                <p>商品清单</p>
                <table>
                    <thead>
                    <tr>
                        <td>商品名称</td>
                        <td >数量</td>
                        <td >单价</td>
                        <td >成交价</td>
                    </tr>
                    </thead>
                    <tbody id="goodsInfo">
                    </tbody>
                </table>
            </div>
            <div>
                <div><label>商品总额：</label><span class="" id="total">0.00</span></div>
                <div><label>服务费：</label><span class="" id="servicePayTotal">0.00</span></div>
            </div>
            <hr/>
        </div>
        <div>
            <p>结算详情</p>
            <div>
                <div><label>会员标识：</label><span class="" id="phone"></span></div>
                <div><label>久零贝支付：</label><span class="" id="coinPayTotal">0.00</span></div>
                <div><label>现金支付：</label><span class="" id="payTotal">0.00</span></div>
                <div><label>购物券消费：</label><span class="">0.00</span></div>
                <div><label>代金券消费：</label><span class="">0.00</span></div>
                <div><label>服务券消费：</label><span class="">0.00</span></div>
            </div>
            <hr/>
        </div>
        <div>
            <div>
                <div><label>代金券赠送：</label><span class="">0.00</span></div>
                <div><label>服务券赠送：</label><span class="">0.00</span></div>
                <div><label>购物券赠送：</label><span class="">0.00</span></div>
            </div>
            <hr/>
        </div>
        <div>
            <div>
                <div><label>消费备注：</label><span class="">大连久零券支付</span></div>
                <div>消费单号：<span id="id"></span></div>
                <div>当前余额：代金券0，服务券0，购物券0</div>
                <div>使用购物券将收10%代金券服务费</div>
                <div>7天内商品不影响再次销售可退换</div>
                <div><label>久零网</label><span class="">www.999000.cn</span></div>
                <div>收银：<span id="userCode"></span>，导购：李东玲</div>
                <div>谢谢光临4008679900</div>
                <div id="date"></div>
            </div>
        </div>
    </div>
    </body>
</div>

<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
<script>

</script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script type="text/javascript">

    //初始化表格对象
    var $table = $('#exampleTablePagination');

    $table.bootstrapTable({
        url: "${pageContext.request.contextPath}/QTMain/queryMoney.ac",
        method: 'post',
        contentType: "application/x-www-form-urlencoded",//必须的
        dataType: "json",
        height: ($(window).height()) ,
        pagination: true, //分页
        singleSelect: false,
        cache:false,
        sortName:"createTime",
        search: false, //显示搜索框
        showColumns:false,
        showRefresh:false,
        showToggle:false,
        showPaginationSwitch:false,
        smartDisplay:true,
        detailView:false,
        toolbar:"#toolbar",
        queryParams: queryParams,//参数
        searchOnEnterKey:true,
        sidePagination: "server", //服务端处理分页
        columns: [
            {
                title: '订单号',
                field: 'code',
                align: 'center'
            },
            {
                title: '客户',
                field: 'custom_name',
                align: 'center'
            },
            {
                title: '收银员',
                field: 'person_name',
                align: 'center'
            },
            {
//                付款途径：0.余额支付 1.银联支付 2.支付宝支付 3.微信支付 4.兴业银行微信支付,6.翼支付，7.offline线下支付
                title: '支付方式',
                field: 'trade_type',
                align: 'center',
                formatter:function(value,row,index){
                    if(value=="MICROPAY"){
                        return "刷卡支付";
                    }else if(value=="NATIVE"){
                        return "扫码支付";
                    }else if(value=="JSAPI"){
                        return "公众号支付";
                    }else if(value=="offline"){
                        return "线下支付";
                    }else if(value=="UNIONPAY"){
                        return "银联支付";
                    }else if(value=="ZFB-MICROPAY"){
                        return "支付宝支付";
                    }
                }
            },
            {
                title: '用券额',
                field: 'payCoupon',
                align: 'center'
            },
            {
                title: '服务费',
                field: 'cash_total',
                align: 'center'
            },
            {
                title: '交易时间',
                field: 'create_time',
                align: 'center',
//                formatter:function(value,row,index){
//                    var d = new Date(value.time);
//                    var month = parseInt(d.getMonth()) + 1;
//                    var str = d.getFullYear() + "-" + month + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
//                    return str;
//                }
            }
        ],
        onDblClickRow: function (row, $element, field) {
            //根据订单号查询商品具体信息
            var code = $element.find("td").eq(0).html();
            prn1_print(code);
        }
    });

    /*
     搜索按钮
     */
    $("#btn_search").click(function(){
        $table.bootstrapTable('selectPage', 1);
        $table.bootstrapTable('refresh', queryParams);
    });

    /*
     传递的参数
     */
    function queryParams(params) {
        var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            limit: params.limit,  //页面大小
            page: params.offset, //页码
            pageindex:params.pageNumber,
            state: $("#state").val()
        };
        return temp;
    }
    ///////////////////////////////////////////////////////////////toolbar///////////////////////////////////////


</script>
<script>
    var LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM')); //声明为全局变量
    //打印预览
    function prn1_preview() {
        CreateOneFormPage();
        LODOP.PREVIEW();
    };
    //直接打印
    function prn1_print(code) {
        CreateOneFormPage(code);
    };
    //选择打印机
    function prn1_printA() {
        CreateOneFormPage();
        LODOP.PRINTA();
    };
    function CreateOneFormPage(code){
        var url="${ctx}/QTMain/findOrderInfoById.ac?id="+code;
        $.get(url,function(data){
            var dataObj=eval("("+data+")");//转换为json对象
            if(dataObj!=null&&dataObj.return_code==1){
                var params =dataObj.return_data;
                var names =params.name.toString().split(",");
                var counts =params.count.toString().split(",");
                var prices =params.price.toString().split(",");
                var goodsTotals =params.goodsTotal.toString().split(",");
                var goodsInfoHtm="";
                $.each(names,function(i){
                    goodsInfoHtm+="<tr>"
                                +"<td>"+this+"</td>"
                                +"<td>"+counts[i]+"</td>"
                                +"<td>"+prices[i]+"</td>"
                                +"<td>"+goodsTotals[i]+"</td>"
                                +"</tr>";
                });
                $("#goodsInfo").html(goodsInfoHtm);//商品信息

                $("#total").html(params.total);//商品总额
                $("#servicePayTotal").html(params.servicePayTotal);//服务费
                $("#phone").html(params.phone);//会员标识
                $("#coinPayTotal").html(params.coinPayTotal);//久零贝支付
                $("#payTotal").html(params.payTotal);//现金支付
                $("#id").html(params.id);//消费单号
                $("#userCode").html(params.userCode);//收银
                $("#date").html(params.date);//日期

                LODOP.PRINT_INITA(0,0,800,651,"久零网QT系统小票打印作业");
                LODOP.SET_PRINT_PAGESIZE(3,"48mm","2mm","");
                LODOP.ADD_PRINT_HTM("2mm","0.5mm","RightMargin:1.5mm","BottomMargin:2mm",document.getElementById("print1").innerHTML);
                //LODOP.PREVIEW();//预览
                LODOP.PRINT();//直接打印
                //LODOP.PRINT_DESIGN();//打印设计
            }
       });
    };
</script>
<script language="javascript" src="${ctxStatic}/plugins/LodopFuncs.js"></script>
</body>


</html>
